
import { createRouter, createWebHistory } from 'vue-router'
const routes = [
  //黄勇铭router
  {
    path: "/",
    name:"",
    component: () => import('../views/ProductRecommend.vue'),
    // redirect: '/person'
  },

  //张宇恒
  {
    path:"/login",
    name:"login",
    component:()=>import('../views/user/Login.vue')
  },

  //详情
  {
    path: '/details',
    name: 'details',
    component: () => import('../views/books/Details.vue')
  },

  //欧信宏
  {
    path: '/person',
    name: 'Person',
    meta: {title: '个人中心'}, 
    component: () => import( '../views/pages/PersonHome.vue'),
    children:[
      {
        path: 'personmessage',
        name: 'personmessage',
        meta: {title: '个人信息'}, 
        component: () => import( '../components/PersonMessge.vue'),
      },
    ]
  },

  //李滨瑶
  {
    path:'/homePage',
    name:'HomePage',
    component:() =>import('../views/homePage/HomePage.vue'),
  }

]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})
//配置一个全局的前置路由守卫
router.beforeEach(async function(to,from){
  if(to.path == '/login'){
      return;
  }else{
    //从会话存储空间获取
    /*
    let token = sessionStorage.getItem("token");
     if(!token){ //没有
        //跳转到登录
        return {name:'login'}
     }else{
        return;
     }
     */
    return;
  }
});
export default router
